package com.jinkaimen.kqb.ui.holder;

import android.widget.ImageView;
import android.widget.TextView;

import com.ht.baselibs.ui.base.BaseViewHolder;
import com.ht.baselibs.utils.DateUtils;
import com.jinkaimen.kqb.R;
import com.jinkaimen.kqb.bean.hss.PublicNewsBean;

/**
 * Created by Admin on 2017/8/14.
 */
public class PublicNewsHolder extends BaseViewHolder<PublicNewsBean.RecordsBean> {

    private TextView mTvShowNews, mTvNewsTime;
    private ImageView mIvPublicNewsIcon;

    public PublicNewsHolder() {
        super(R.layout.list_public_news_item);
    }

    @Override
    protected void initView() {
        mTvShowNews = findViewById(R.id.tv_show_news);
        mTvNewsTime = findViewById(R.id.tv_news_time);
        mIvPublicNewsIcon = findViewById(R.id.iv_public_news_icon);
    }

    @Override
    protected void refreshView(PublicNewsBean.RecordsBean recordsBean) {
        mTvShowNews.setText(recordsBean.title);
        long time = recordsBean.createTime.time;
        if (time != 0) {
            String timeHMS = DateUtils.formatDateTimeHMS(time);
            mTvNewsTime.setText(timeHMS);
        }
        mIvPublicNewsIcon.setImageResource("2".equals(recordsBean.type) ? R.mipmap.remind_icon : R.mipmap.safeguard_icon);
    }
}
